<!DOCTYPE html>
<html lang="en">
@include("/common/head.html"){}
<body>

<div class="header">
    <div class="main">
        <div class="nav-user">
            <a href="user/login">登录</a>
            <a href="user/register">注册</a>
        </div>
    </div>
</div>

<div class="main layui-clear">
    <div id="app-2">
      <span v-bind:title="message">
        鼠标悬停几秒钟查看此处动态绑定的提示信息！
      </span>
    </div>
    <div id="fetchIdTest">
        {{ testList }}
        <button v-on:click="testFetch">测试fetch</button>
    </div>
</div>


<div class="footer">
</div>
<script src="${ctxPath}/resources/js/vue.js"></script>
<script src="${ctxPath}/resources/js/fetch.js"></script>
<script src="${ctxPath}/resources/layui/layui.js"></script>
<script>
    var test = new Vue({
        el:"#fetchIdTest",
        data:{testList:''},
        methods:{
            testFetch:function () {
                fetch('${ctxPath}/resources/json/test.json')
                    .then(function(response) {
                        return response.json()
                    }).then(function(json) {
                    console.log('parsed json', json);
                    test.testList = json.name+json.main;
                }).catch(function(ex) {
                    console.log('parsing failed', ex)
                })
            }
        }
    });


    var app2 = new Vue({
        el: '#app-2',
        data: {
            message: '页面加载于 ' + new Date()
        }
    })
</script>
<script>
    layui.config({
        version: false //一般用于更新模块缓存，默认不开启。设为true即让浏览器不缓存。也可以设为一个固定的值，如：201610
        ,debug: true //用于开启调试模式，默认false，如果设为true，则JS模块的节点会保留在页面
        ,base: '' //设定扩展的Layui模块的所在目录，一般用于外部模块扩展
    });
</script>
</body>
</html>